package com.koron.css2.newProjectCenter.impl.print;

import com.koron.css2.ServerInterface;
import com.koron.css2.newProjectCenter.bean.PjMeter;
import com.koron.css2.newProjectCenter.bean.query.PjMeterQuery;
import com.koron.css2.newProjectCenter.dto.IdsDto;
import com.koron.css2.newProjectCenter.mapper.PjMeterMapper;
import com.koron.css2.serviceManage.bean.RequestBean;
import com.koron.css2.serviceManage.bean.UserInfoBean;
import com.koron.css2.serviceManage.utils.JsonUtils;
import com.koron.util.Constant;
import org.koron.ebs.mybatis.SessionFactory;
import org.swan.bean.MessageBean;

import java.util.HashMap;
import java.util.List;

/**
 * 水表领用单据打印
 */
public class PjMeterUsePrint implements ServerInterface {
    @Override
    public MessageBean<?> exec(SessionFactory factory, UserInfoBean userInfo, RequestBean req) {
        try {
            IdsDto idsDto = JsonUtils.objectToPojo(req.getData(), IdsDto.class);
            List<String> ids = idsDto.getIds();


            // 3. 返回打印id
            MessageBean<List> messageBean = MessageBean.create(Constant.MESSAGE_INT_SUCCESS, "施工合同模板打印成功", List.class);

            return messageBean;
        } catch (Exception e) {
            logger.error("施工合同模板打印数据获取失败", e);
            return MessageBean.create(Constant.MESSAGE_INT_FAIL, "施工合同模板打印失败", null);
        }
    }

    private List<HashMap<String, String>> getPrintDate(SessionFactory factory, List<String> pjMeterIdList, UserInfoBean userInfo) {
        PjMeterMapper pjMeterMapper = factory.getMapper(PjMeterMapper.class);
        for (String pjMeterId : pjMeterIdList){
            PjMeterQuery query = new PjMeterQuery();
            query.setId(pjMeterId);
            PjMeter pjMeter = pjMeterMapper.getSingle(query);

        }
        return null;
    }
}
